package com.jekun.helloworld.designmode.composite.demo01;

import java.util.*;

/**
 * @author Administrator
 */
public class Plate implements MyElement {
    private ArrayList<MyElement> list = new ArrayList<>();

    public void add(MyElement element) {
        list.add(element);
    }

    public void delete(MyElement element) {
        list.remove(element);
    }

    @Override
    public String eat() {
        StringBuilder builder = new StringBuilder();
        for (MyElement object : list) {
            builder.append(object.eat());
        }
        return builder.toString();
    }
}